Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Adding AutomationML serializer#5

Merged
sebbader merged 27 commits intomainfrom
feature/aml
Aug 19, 2021
Merged

Adding AutomationML serializer#5
sebbader merged 27 commits intomainfrom
feature/aml

Conversation

@mjacoby
Copy link
Copy Markdown
Contributor

@mjacoby mjacoby commented Aug 17, 2021

This PR adds the AutomationML serializer.

mjacoby and others added 25 commits July 8, 2021 10:08
- added unit test to AML serializer
@mjacoby mjacoby requested a review from sebbader August 17, 2021 07:58
 into feature/aml

# Conflicts:
#	README.md
#	dataformat-rdf/license-header.txt
private final AmlDeserializer deserializer = new AmlDeserializer();

@Test
@Ignore
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that the test is ignored?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as AmlDeserializer is not yet fully implemented and therefore the test would fail.

*/
package io.adminshell.aas.v3.dataformat.aml.serialize;

import io.adminshell.aas.v3.dataformat.aml.fixtures.FullExample;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FullExample.java file is meant to be reused from other tests too? Maybe consider moving the AAS objects created for this test in the same file to make it independent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right (in general). We are already working on this, however, FullExample is currently not 100% consistent acrosss different serialization formats. The reason for this is, that when implementing AML we realized that the full example is actually not 100% valid according to the constraints but this has not caused issues in other serialization formats as they are more "error-friendly" e.g. unresolvable references do not cause JSON serializer to crash as references are just serialized as string whereas in AML unresolvable references can cause a crash because sometimes these references are resolved and the referenced element is inlined.
We are working on unifying FullExample.java but we postponed this task until validation is implemeted and we can be sure that we fix all issues in the FullExample in one go as this requires slight adjustments to the expected results of the unit tests of all serializers.

.normalizeWhitespace()
.withNodeMatcher(new DefaultNodeMatcher(
ElementSelectors.conditionalBuilder()
.whenElementIsNamed("Attribute")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me the usage of these when...then statements in the for the test assertion. Is is a kind of mapping that could have been done at an earlier stage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are instructions on how to compare the generated XML/AML to the expected XML/AML. The used framework only works on XML and compares nodes of the XML tree based on node name which in case of AML is most of the time either Attribute or InternalElement. As in AML each element typically has multiple sub-elements of type Attribute and/or InternalElement. These statements specify that e.g. an element is named "Attribute" it should be compare not with another element named "Attribute" at the same position in the other file but with another element that is also named "Attribute" and has the same value for attribute "Name".
Basically, these rules define how to uniquely identify an Attribute/InternalElement/ExternalInterface so that order of elements is not important when comparing AML files.

@sebbader sebbader merged commit 9b728f1 into main Aug 19, 2021
@sebbader sebbader deleted the feature/aml branch August 19, 2021 06:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants